﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ChangeStyleCopRule.cs" company="StyleCop for ReSharper Development Team">
//   Copyright (c) StyleCop for ReSharper Development Team. All rights reserved.
// </copyright>
// <summary>
//   Defines the ChangeStyleCopRule type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

extern alias JB;

namespace StyleCop.For.ReSharper.QuickFixes.Framework
{
    #region Using Directives

    using System.Collections.Generic;

    using JetBrains.DocumentModel;
    using JetBrains.ReSharper.Daemon;
    using JetBrains.ReSharper.Feature.Services.Bulbs;
    using JetBrains.Util;

    using StyleCop.For.ReSharper.Options;
    using StyleCop.For.ReSharper.Violations;

    #endregion

    /// <summary>
    /// DisableHighlightingActionProvider for StyleCop rules.
    /// </summary>
    [DisableHighlightingActionProvider]
    public class ChangeStyleCopRule : IDisableHighlightingActionProvider
    {
        /// <summary>
        /// Gets the actions for changing the highlight options for StyleCop rules.
        /// </summary>
        /// <param name="highlighting">
        /// The current highlighting.
        /// </param>
        /// <param name="highlightingRange">
        /// The current highlighting range.
        /// </param>
        /// <returns>
        /// The available actions.
        /// </returns>
        public ICollection<IDisableHighlightingAction> Actions(IHighlighting highlighting, DocumentRange highlightingRange)
        {
            var violation = highlighting as StyleCopViolationBase;

            if (violation == null)
            {
                return JB::JetBrains.Util.EmptyArray<IDisableHighlightingAction>.Instance;
            }

            var ruleID = violation.CheckId;
            var highlightID = HighlightingRegistering.GetHighlightID(ruleID);

            return new IDisableHighlightingAction[] { new ChangeStyleCopRuleAction { HighlightID = highlightID, Text = "Inspection Options for \"" + violation.ToolTip + "\"" } };
        }
    }
}